<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../../vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root"></div>
</body>
<script>

    // 定义student组件
    const student = {
        name: 'student',
        template: `<h2>{{age}}</h2>`,
        data() {
            return {
                age: 18
            }
        },
    }

    // 定义school组件
    const school = {
        template: `
        <div>
            <h2>学校:{{name}}</h2>
            <student></student>
        </div>
        `,
        data() {
            return {
                name: '1123'
            }
        },
        components: {
            student
        }
    }

    // 定义hello组件
    const hello = {
        template: `
            <h2>{{msg}}</h2>
        `,
        data() {
            return {
                msg: 'hello'
            }
        }
    }

    // 定义app组件
    const app = {
        template: `
            <div>
                <school></school>
                <hello></hello>
            </div>
        `,
        components: {
            school,
            hello
        }
    }


    const vm = new Vue({
        template: `<app></app>`,
        // 局部注册
        components: {
            app
        }
    }).$mount('#root')

</script>

</html>